package Controls;

import java.util.List;

import android.content.Context;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import etc.com.market.R;
import etc.com.market.MarketSystem;


public class SermonDetailAdapter extends BaseAdapter {
	private Context context;	
	private MarketSystem app;
	private boolean m_isTuyenBus;
	private List<SermonDetailVO> listSermonDetail;

	public SermonDetailAdapter(Context context, List<SermonDetailVO> listSermonDetail) {
		this.context = context;
		this.listSermonDetail = listSermonDetail;	
		app = (MarketSystem)context.getApplicationContext();
	}

	public int getCount() {
		return listSermonDetail.size();
	}

	public Object getItem(int position) {
		return listSermonDetail.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View view, ViewGroup viewGroup) {
		SermonDetailVO entry = listSermonDetail.get(position);
		return new SermonDetailAdapterView(context, entry);
	}
	
	private class SermonDetailAdapterView extends LinearLayout {
		
		
		private SermonDetailVO m_vo;
		public SermonDetailAdapterView(final Context context, SermonDetailVO entry) {
			super(context);

			this.setOrientation(VERTICAL);
			this.setTag(entry);
		
		
			m_vo = entry;
			View v ;
			v = inflate(context, R.layout.sermon_detail_list_item, null);
		
			TextView txtName = (TextView) v.findViewById(R.id.txtName);
			txtName.setText(Html.fromHtml("<ul><li>  " + entry.getDesc1() + "</li></ul> "));			
			
		    TextView txtDateTime = (TextView) v.findViewById(R.id.txtDateTime);
		    txtDateTime.setText(Html.fromHtml("<ul><li>  " + DateHelper.SqlDateToString(entry.getDateTime()) 
		    		+ "</li></ul> "));
			addView(v);
		}
	}
}


